<template>
	<div>
		<!-- <van-nav-bar
			:title="title"
			:fixed="true"
		/> -->
		
		<van-tabbar v-model="active" active-color="#d4616e" inactive-color="#000">
		  <van-tabbar-item icon="wap-home-o" to="/home">首页</van-tabbar-item>
		  <van-tabbar-item icon="shop-o" to="/mendian">门店</van-tabbar-item>
		  <van-tabbar-item icon="more-o" to="/quan">甜甜圈</van-tabbar-item>
		  <van-tabbar-item icon="bag-o" @click="gouwu" :info="cont">购物车</van-tabbar-item>
		  <van-tabbar-item icon="user-circle-o" @click="my">我的</van-tabbar-item>
		</van-tabbar>
		
		<div id="container">
			<van-pull-refresh v-model="isLoading" @refresh="onRefresh">
				<router-view @toparent="getval" @toIndex="getcount"></router-view>
			</van-pull-refresh>
		</div>
	</div>
</template>

<script>
	export default{
		name:"Index",
		data(){
			return{
				active:0,
				title:"首页",
				isLoading: false,
				value:'',
				cont:'',
			}
		},
		methods:{
			getcount(count){
				console.log(count)
				this.cont=count
			},
			getval(msg){
				console.log(msg)
				this.title=msg
			},
			onRefresh() {
				setTimeout(() => {
			        this.$toast('刷新成功');
			        this.isLoading = false;
				}, 2000);
			},
			gouwu(){
				if(!localStorage.getItem('token')){
					this.$router.push('/login')
				}else{
					this.$router.push('/cart')
				}
			},
			my(){
				if(!localStorage.getItem('token')){
					this.$router.push('/login')
				}else{
					this.$router.push('/my')
				}
			},
		}
	}
</script>

<style scoped="">
	#container{
		margin-bottom:50px;
	}
	
	
</style>
